package container;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Contains a list of weapons.
 * 
 * @author Marcus
 * 
 */
@XmlRootElement
public class Weapons {

	public Weapons() {
		this.weapons = new ArrayList<Weapon>();
	}

	private List<Weapon> weapons;

	/**
	 * Adds the passed weapon to the list.
	 * 
	 * @param weapon
	 *            weapon to add
	 */
	public void addWeapon(Weapon weapon) {
		if (weapon == null) {
			throw new IllegalArgumentException(
					"Passed weapon cannot be 'null'.");
		}
		this.weapons.add(weapon);
		// Sorting the weapons
		Collections.sort(this.weapons);
	}

	/**
	 * Removes the passed weapon from the list.
	 * 
	 * @param weapon
	 */
	public void removeWeapon(Weapon weapon) {
		this.weapons.remove(weapon);
	}

	/**
	 * Returns the weapon list.
	 * 
	 * @return all weapons
	 */
	@XmlElement(name = "Weapon")
	public List<Weapon> getWeapons() {
		return this.weapons;
	}

	/**
	 * Sets the weapon list.
	 * 
	 * @param setWeapons
	 */
	public void setWeapons(List<Weapon> setWeapons) {
		this.weapons = setWeapons;
	}
}
